import java.io.File;


public class DeleteDir {
	static int ind = 0;
	 // Deletes all files and subdirectories under dir.
    // Returns true if all deletions were successful.
    // If a deletion fails, the method stops attempting to delete and returns false.
    public static boolean deleteDir(File dir) {
        if (dir.isDirectory()) {
            String[] children = dir.list();
            for (int i=0; i<children.length; i++) {
                boolean success = deleteDir(new File(dir, children[i]));
                if (!success) {
                	System.out.println("dlete fail "+dir + File.separator+ children[i]);
                }else {
                	if(ind % 500 == 0)
                	System.out.println(ind + " dlete success "+dir +File.separator+ children[i]);
                    ind++;
                }
            }
           // return true;
        }
       // System.out.println(dir.getName() + "  "+dir.isDirectory());
    
        // The directory is now empty so delete it
        return dir.delete();
    }
	public static void main(String[] args) {
		String d = "C:\\ZendServer\\Zend\\Apache2\\htdocs\\multistore\\jayaram1";
		boolean dstatus = deleteDir(new File(d));
		System.out.println("delete dir "+dstatus);
	}
	
}
